package com.hlkj.baojin.entity;

import lombok.Getter;
import lombok.Setter;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.index.IndexDirection;
import org.springframework.data.mongodb.core.index.Indexed;
import org.springframework.data.mongodb.core.mapping.Document;

import java.io.Serializable;
import java.util.List;

@Document
@Getter
@Setter
public class User implements Serializable {

    @Id
    private String id;
    @Indexed(unique = true, direction = IndexDirection.DESCENDING, dropDups = true)
    private String username;
    private String password;
    /**
     * 所属部门
     */
    private String deptId;

    /**
     * 类型 1 公司 2 后台管理员
     */
    private Integer type;

    /**
     * 最后一次修改密码时间
     */
    private Long lastPasswordResetDate;

    /**
     * 角色权限
     */
    private List<String> roles;

    private String smsCode;

    private Long smsCodeSendTime;

    public User(String username, String password, String deptId, Integer type, List<String> roles) {
        this.username = username;
        this.password = password;
        this.deptId = deptId;
        this.type = type;
        this.lastPasswordResetDate = System.currentTimeMillis();
        this.roles = roles;
    }

}
